home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************\
- | |
- | CURLPushButton.h ©1997 John C. Daub. All rights reserved |
- | |
- | See the file "CURLPushButton README" for full details, instructions, changes, |
- | licensing agreement, etc. Due to the important information included in that |
- | file, if you did not receive a copy of it, please contact the author for |
- | a copy. |
- | |
- | John C. Daub <mailto:hsoi@eden.com> |
- | <http://www.eden.com/~hsoi/> <http://www.eden.com/~hsoi/prog.html> |
- | |
- \*******************************************************************************/
-
- #ifndef _H_CURLPushButton
- #define _H_CURLPushButton
-
- #pragma once
-
- #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
- #pragma import on
- #endif
-
- // Having this macro true will enhance CURLPushButton by giving it drag and
- // drop support. If you desire no such thing (and all the extra code it can
- // bring in), #define this to be false somewhere (e.g. prefix file) and all
- // the drag and drop code will be preprocessed out.
-
- #ifndef _CURLPushButton_DO_DND_
- #define _CURLPushButton_DO_DND_ 1
- #endif
-
-
- #include <PP_Prefix.h>
- #include <LControl.h>
- #include <LString.h>
-
- // the following struct were created for and should only be
- // used for the parameterized constructor
-
- #pragma options align=mac68k
-
- typedef struct {
- // following 4 are input params for an LControl
-
- MessageT valueMessage;
- Int32 value;
- Int32 minValue;
- Int32 maxValue;
-
- Str255 titleText;
- ResIDT textTraitsID;
-
- ResIDT hiliteTextTraitsID;
- Boolean useHiliteColor;
- RGBColor hiliteColor;
- Str255 URL;
-
- Boolean useInvertRect;
-
- } SURLpbInfo, *SURLpbInfoPtr, **SURLpbInfoHandle;
-
- #pragma options align=reset
-
-
-
- class CURLPushButton : public LControl {
-
- public:
-
- enum { class_ID = 'URpb' };
-
- #if ( __PowerPlant__ < 0x01608000 ) // version 1.6/CW11
- static CURLPushButton* CreateFromStream( LStream *inStream );
- #endif
-
- CURLPushButton();
- CURLPushButton(const CURLPushButton &inOriginal );
- CURLPushButton(const SPaneInfo &inPaneInfo,
- const SURLpbInfo &inParamInfo );
- CURLPushButton( LStream *inStream );
- virtual ~CURLPushButton();
-
- CURLPushButton& operator=( const CURLPushButton &inOriginal );
-
- virtual void SetValue( Int32 inValue );
-
- virtual StringPtr GetURL();
- virtual StringPtr GetURL( Str255 outURL ) const;
- virtual void SetURL( ConstStr255Param inURL );
-
- virtual StringPtr GetDescriptor();
- virtual StringPtr GetDescriptor( Str255 outDescriptor ) const;
- virtual void SetDescriptor( ConstStr255Param inDescriptor );
-
- virtual Boolean GetInvertRect() const;
- virtual void SetInvertRect( const Boolean inUseInvert );
- virtual Boolean GetUseInvertRect() const;
- virtual void SetUseInvertRect( const Boolean inUseInvert );
-
- virtual ResIDT GetTextTraitsID() const;
- virtual void SetTextTraitsID( const ResIDT inResID );
-
- virtual ResIDT GetHiliteTextTraitsID() const;
- virtual void SetHiliteTextTraitsID( const ResIDT inResID );
-
- virtual Boolean GetUseHiliteColor() const;
- virtual void SetUseHiliteColor( Boolean inUseHiliteColor );
-
- virtual void GetHiliteColor( RGBColor &outColor ) const;
- virtual void SetHiliteColor( const RGBColor &inHiliteColor );
- virtual void SetHiliteColor( const Uint8 inRed,
- const Uint8 inGreen, const Uint8 inBlue );
-
- #if _CURLPushButton_DO_DND_
- virtual Boolean GetDoDragAndDrop() const;
- virtual void SetDoDragAndDrop( const Boolean inDoDragAndDrop );
- #endif
-
-
- protected:
-
- #if _CURLPushButton_DO_DND_
- virtual void ClickSelf(const SMouseDownEvent &inMouseDown );
- virtual void CreateDragEvent( const SMouseDownEvent &inMouseDown );
- #endif
-
- virtual void DrawSelf();
-
- virtual void ActivateSelf();
- virtual void DeactivateSelf();
-
- virtual void HotSpotResult( Int16 inHotSpot );
- virtual void HotSpotAction(
- Int16 inHotSpot,
- Boolean inCurrInside,
- Boolean inPrevInside);
-
-
- private:
-
- LStr255 mTitleText;
- ResIDT mTextTraitsID;
- LStr255 mURL;
- ResIDT mHiliteTextTraitsID;
- Boolean mUseHiliteColor;
- RGBColor mHiliteColor;
- Boolean mUseInvertRect;
-
- #if _CURLPushButton_DO_DND_
- Boolean mDoDragAndDrop;
- #endif
-
- };
-
-
- //========================================================================
- // ••• Inlines
- //========================================================================
-
-
- //========================================================================
- // • GetTextTraitsID [public, virtual]
- //========================================================================
- // Return the Txtr ResIDT
-
- inline
- ResIDT
- CURLPushButton::GetTextTraitsID() const
- {
- return mTextTraitsID;
- }
-
-
- //========================================================================
- // • SetTextTraitsID [public, virtual]
- //========================================================================
- // Set the text traits to the given ResIDT
-
- inline
- void
- CURLPushButton::SetTextTraitsID(
- const ResIDT inResIDT )
- {
- mTextTraitsID = inResIDT;
- }
-
-
- //========================================================================
- // • GetHiliteTextTraitsID [public, virtual]
- //========================================================================
- // Return the Txtr ResIDT
-
- inline
- ResIDT
- CURLPushButton::GetHiliteTextTraitsID() const
- {
- return mHiliteTextTraitsID;
- }
-
-
- //========================================================================
- // • SetHiliteTextTraitsID [public, virtual]
- //========================================================================
- // Set the hilite text traits to the given ResIDT
-
- inline
- void
- CURLPushButton::SetHiliteTextTraitsID(
- const ResIDT inResIDT )
- {
- mHiliteTextTraitsID = inResIDT;
- }
-
-
- //========================================================================
- // • GetUseHiliteColor [public, virtual]
- //========================================================================
- // Return true if using hilite color or false if not
-
- inline
- Boolean
- CURLPushButton::GetUseHiliteColor() const
- {
- return mUseHiliteColor;
- }
-
-
- //========================================================================
- // • SetUseHiliteColor [public, virtual]
- //========================================================================
- // Used to set if we should use the hilite color or not
-
- inline
- void
- CURLPushButton::SetUseHiliteColor(
- const Boolean inUseHiliteColor )
- {
- mUseHiliteColor = inUseHiliteColor;
- }
-
-
- //========================================================================
- // • GetHiliteColor [public, virtual]
- //========================================================================
- // Return the hilite color
-
- inline
- void
- CURLPushButton::GetHiliteColor( RGBColor &outColor ) const
- {
- outColor.red = mHiliteColor.red;
- outColor.green = mHiliteColor.green;
- outColor.blue = mHiliteColor.blue;
- }
-
-
- //========================================================================
- // • SetHiliteColor [public, virtual]
- //========================================================================
- // Set the hilite color to the given RGBColor
-
- inline
- void
- CURLPushButton::SetHiliteColor(
- const RGBColor &inHiliteColor )
- {
- mHiliteColor.red = inHiliteColor.red;
- mHiliteColor.green = inHiliteColor.green;
- mHiliteColor.blue = inHiliteColor.blue;
- }
-
- //========================================================================
- // • SetHiliteColor [public, virtual]
- //========================================================================
- // Set the hilite color to the given red, green, and blue values
-
- inline
- void
- CURLPushButton::SetHiliteColor(
- const Uint8 inRed,
- const Uint8 inGreen,
- const Uint8 inBlue )
- {
- mHiliteColor.red = inRed;
- mHiliteColor.green = inGreen;
- mHiliteColor.blue = inBlue;
- }
-
-
- //========================================================================
- // • SetInvertRect [public, virtual]
- //========================================================================
- // Used to modify the behavior of HotSpotAction. If you want to use
- // InvertRect to give the visual feedback, then this accessor routine
- // will allow you to set the behavior as such
- //
- // This name is obsolete. Please use SetUseInvertRect() instead.
-
- inline
- void
- CURLPushButton::SetInvertRect(
- const Boolean inUseInvert )
- {
- mUseInvertRect = inUseInvert;
- }
-
-
- //========================================================================
- // • GetInvertRect [public, virtual]
- //========================================================================
- // Determine if this object is using InvertRect (or not) for its behavior
- // in HotSpotAction.
- //
- // This name is obsolete. Please use GetUseInvertRect() instead.
-
- inline
- Boolean
- CURLPushButton::GetInvertRect() const
- {
- return mUseInvertRect;
- }
-
-
- //========================================================================
- // • GetUseInvertRect & SetUseInvertRect [public, virtual]
- //========================================================================
- // GetInvertRect and SetInvertRect existed for a long time, but don't
- // conform to the method accessor naming convention. I'm leaving in the
- // original routines for backwards compatability, but also adding these new
- // named routines for consistancy with the naming convention.
- //
- // Please use these methods for any new code.
-
- inline
- void
- CURLPushButton::SetUseInvertRect(
- const Boolean inUseInvert )
- {
- mUseInvertRect = inUseInvert;
- }
-
-
- inline
- Boolean
- CURLPushButton::GetUseInvertRect() const
- {
- return mUseInvertRect;
- }
-
-
- // these functions are only used if we are supporting drag and drop
-
- #if _CURLPushButton_DO_DND_
-
- //========================================================================
- // • GetDoDragAndDrop [public, virtual]
- //========================================================================
- // Return true if this object does drag and drop support
-
- inline
- Boolean
- CURLPushButton::GetDoDragAndDrop() const
- {
- return mDoDragAndDrop;
- }
-
-
- //========================================================================
- // • SetDoDragAndDrop [public, virtual]
- //========================================================================
- // Set if this object will support drag and drop or not
-
- inline
- void
- CURLPushButton::SetDoDragAndDrop(
- const Boolean inDoDragAndDrop )
- {
- mDoDragAndDrop = inDoDragAndDrop;
- }
-
- #endif // _CURLPushButton_DO_DND_
-
-
-
- #if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
- #pragma import reset
- #endif
-
- #endif /* _H_CURLPushButton */